package com.ruitu.mall_98_1.mvp.model;

import com.ruitu.mall_98_1.dao.api.APIRetrofit;
import com.ruitu.mall_98_1.mvp.contract.MainHomeContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.app.HomeData;
import com.ruitu.router_module.bean.app.RongToken;

import rx.Observable;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

/**
 * Created by Administrator on 2018/11/02
 */
public class MainHomeModelImpl implements MainHomeContract.Model {

    @Override
    public Observable<BaseResult<HomeData>> reqAppHome(String cityName, String accountId) {
        return APIRetrofit.getDefault().reqAppHome(cityName, accountId).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<RongToken> reqRongToken(String appKey, String nonce, String timeStamp
            , String signiture, String userId, String userName, String portraitUri) {
        return APIRetrofit.getRongApi().reqRongToken(appKey, nonce, timeStamp, signiture
                , userId, userName, portraitUri)
                .subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread());
    }

    @Override
    public Observable<BaseResult<Integer>> reqUnReadNum(String accountId) {
        return APIRetrofit.getDefault().reqUnReadNum(accountId).subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    }
}